#if !SERVER
using ActorSystem;
using Net.Client;
using Net.Common;
using Net.Share;
using UnityEngine;

namespace AOIExample
{
    public partial class Player : Actor
    {
        protected override ActorView GetViewPrefab()
        {
            return Object.FindAnyObjectByType<SceneManager>().actorViews[0];
        }

        public override void OnUpdate()
        {
            if (View == null)
                return;
            if (!IsLocal)
            {
                View.transform.position = Vector3.Lerp(View.transform.position, transform.Position, 0.25f);
                View.transform.rotation = Quaternion.Lerp(View.transform.rotation, transform.Rotation, 0.25f);
            }
            else
            {
                var dir = Camera.main.transform.Transform3Dir();
                if (dir != Vector3.zero)
                {
                    View.transform.rotation = Quaternion.Lerp(View.transform.rotation, Quaternion.LookRotation(dir, Vector3.up), 0.5f);
                    View.transform.Translate(0, 0, moveSpeed * Net.Entities.Time.deltaTime);
                    ClientBase.Instance.AddOperation(new Operation(OperCommand.SyncPosition, Identity, View.transform.position, View.transform.rotation));
                }
            }
        }
    }
}
#endif